require "./simple_input"
require "./scripts/play_scene/player"

module DGame
    RED = StarRuby::Color.new(245, 0, 0, 255)
    GRAY = StarRuby::Color.new(208, 208, 208, 255)
    YELLOW = StarRuby::Color.new(255, 255, 168, 255)
  class PlayScene

    def initialize
      @texture = $res.get_texture("game/sample", false)
      
      data = @texture.dump("rgb")
      tx = 0
      ty = 0
      0.step(data.length, 3)do |i|
        tx = (i / 3) % SCREEN_WIDTH
        ty = (i / 3) / SCREEN_WIDTH
        if data[i] == RED.red && data[i + 1] == RED.green && data[i + 2] == RED.blue
          break
        end
      end
      @player = Player.new(tx, ty)
      
    end

    def update(stack)
      @player.update(@texture)
    end

    def render(s)
      s.render_texture(@texture, 0, 0)
      @player.render(s)
    end
  end
end